﻿<controlBase:NavigationBase x:Class="Rio.Framework.Pages.Controls.DocumentRibbonBar"
                            x:Name="ribbonBar"
                            xmlns:control="clr-namespace:Rio.Framework.Pages.Controls.Navigation"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                            xmlns:telerikRibbon="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonView"
                            xmlns:controlBase="clr-namespace:Rio.Framework.Pages.Controls.BaseClass.Navigation">

    <controlBase:NavigationBase.Resources>

        <DataTemplate x:Name="QuickAccessButtonTemplate">
            <telerikRibbon:RadRibbonButton Margin="2,0,0,0"
                                           Command="{Binding ClickCommand, ElementName=ribbonBar, Mode=TwoWay}"
                                           CommandParameter="{Binding Name}"
                                           ToolTipService.ToolTip="{Binding Text}"
                                           HorizontalAlignment="Stretch"
                                           IsEnabled="{Binding IsEnabled}"
                                           Visibility="{Binding IsVisible}"
                                           SmallImage="{Binding SmallImage}"
                                           Height="24"/>
        </DataTemplate>

        <DataTemplate x:Name="ButtonTemplate">
            <telerikRibbon:RadRibbonButton Text="{Binding Text}" 
                                           Size="{Binding Size}" 
                                           Command="{Binding ClickCommand, ElementName=ribbonBar, Mode=TwoWay}"
                                           CommandParameter="{Binding Name}"
                                           CollapseToSmall="WhenGroupIsSmall"
                                           ToolTipService.ToolTip="{Binding Text}"
                                           IsEnabled="{Binding IsEnabled}"
                                           SmallImage="{Binding SmallImage}" 
                                           LargeImage="{Binding LargeImage}" />
        </DataTemplate>

        <DataTemplate x:Name="SmallButtonTemplate">
            <telerikRibbon:RadRibbonButton Text="{Binding Text}"
                                           Size="Medium"
                                           CollapseToSmall="WhenGroupIsSmall"
                                           Command="{Binding ClickCommand, ElementName=ribbonBar, Mode=TwoWay}"
                                           CommandParameter="{Binding Name}"
                                           ToolTipService.ToolTip="{Binding Text}"
                                           IsEnabled="{Binding IsEnabled}"
                                           SmallImage="{Binding SmallImage}" />
        </DataTemplate>


        <telerik:HierarchicalDataTemplate  x:Name="MenuItemsTemplate">
            <telerik:ContainerBinding.ContainerBindings>
                <telerik:ContainerBindingCollection>
                    <telerik:ContainerBinding PropertyName="Icon" Binding="{Binding Icon}" />
                    <telerik:ContainerBinding PropertyName="IsEnabled" Binding="{Binding IsEnabled}" />
                    <telerik:ContainerBinding PropertyName="Command" Binding="{Binding ClickCommand, ElementName=ribbonBar, Mode=TwoWay}" />
                    <telerik:ContainerBinding PropertyName="CommandParameter" Binding="{Binding Name}" />
                </telerik:ContainerBindingCollection>
            </telerik:ContainerBinding.ContainerBindings>
            <TextBlock Text="{Binding Text}" />
        </telerik:HierarchicalDataTemplate >

        <DataTemplate x:Name="DropDownButtonTemplate">
            <telerikRibbon:RadRibbonDropDownButton Text="{Binding Text}" 
                                                   Size="{Binding Size}"
                                                   CollapseToMedium="WhenGroupIsSmall"
                                                   ToolTipService.ToolTip="{Binding Text}"
                                                   IsEnabled="{Binding IsEnabled}"
                                                   SmallImage="{Binding SmallImage}" 
                                                   LargeImage="{Binding LargeImage}">

                <telerikRibbon:RadRibbonDropDownButton.DropDownContent>
                    <StackPanel>
                        <telerikRibbon:RadGroupHeader Content="{Binding Text}"  />
                        <telerik:RadContextMenu BorderThickness="0" 
                                                ItemsSource="{Binding MenuItems}"
                                                ItemTemplate="{StaticResource MenuItemsTemplate}">
                        </telerik:RadContextMenu>
                    </StackPanel>
                </telerikRibbon:RadRibbonDropDownButton.DropDownContent>
            </telerikRibbon:RadRibbonDropDownButton>
        </DataTemplate>

        <DataTemplate x:Name="SmallButtonGroup">
            <telerik:ItemsControl ItemsSource="{Binding Buttons}" 
                                  ItemTemplate="{StaticResource SmallButtonTemplate}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <telerik:RadCollapsiblePanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </telerik:ItemsControl>
        </DataTemplate>

        <DataTemplate x:Name="ButtonsGroup">
            <telerik:ItemsControl ItemsSource="{Binding Buttons}" 
                                  ItemTemplate="{StaticResource ButtonTemplate}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <telerikRibbon:RadCollapsiblePanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </telerik:ItemsControl>
        </DataTemplate>

        <control:ButtonsTemplateSelector x:Key="groupsSelector" Button="{StaticResource ButtonTemplate}"
                                         DropDownButton="{StaticResource DropDownButtonTemplate}" 
                                         ButtonsGroup="{StaticResource ButtonsGroup}"
                                         SmallButtonGroup="{StaticResource SmallButtonGroup}" />

        <telerik:HierarchicalDataTemplate x:Name="GroupHeaderTemplate" 
                                          ItemsSource="{Binding Buttons}"
                                          ItemTemplateSelector="{StaticResource groupsSelector}">
            <TextBlock Text="{Binding Text}" />
        </telerik:HierarchicalDataTemplate>

        <telerik:ContainerBindingCollection x:Key="tabBindings"></telerik:ContainerBindingCollection>

        <telerik:HierarchicalDataTemplate x:Name="TabTemplate" 
                                          ItemsSource="{Binding Groups}"
                                          telerik:ContainerBinding.ContainerBindings="{StaticResource tabBindings}"
                                          ItemTemplate="{StaticResource GroupHeaderTemplate}">
            <TextBlock Text="{Binding Text}" />
        </telerik:HierarchicalDataTemplate>

    </controlBase:NavigationBase.Resources>

    <telerikRibbon:RadRibbonView  ApplicationButtonVisibility="Collapsed"
                                  x:Name="DocumentRibbonbarElement"
                                  IsMinimized="True"
                                  IsMinimizable="True"
                                  MinimizeButtonVisibility="Visible"
                                  ApplicationName=""
                                  TitleBarVisibility="Visible"
                                  ItemsSource="{Binding Tabs, ElementName=ribbonBar}" 
				                  ItemTemplate="{StaticResource TabTemplate}" QuickAccessToolBarPosition="AboveRibbon">

        <telerikRibbon:RadRibbonView.QuickAccessToolBar>
            <telerikRibbon:QuickAccessToolBar x:Name="DocumentQuickAccessElement"
                                              CustomizationMenuVisibility="Collapsed"
                                              ItemTemplate="{StaticResource QuickAccessButtonTemplate}"
                                              ItemsSource="{Binding QuickAccessButtons, ElementName=ribbonBar}">
            </telerikRibbon:QuickAccessToolBar>
        </telerikRibbon:RadRibbonView.QuickAccessToolBar>
    </telerikRibbon:RadRibbonView>
</controlBase:NavigationBase>
    
